package com.service.admin.trading.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.service.admin.trading.service.TradingSpotTradesService;
import com.service.dao.mapper.TradingSpotTradesMapper;
import com.service.dao.model.TradingSpotTrades;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("tradingSpotTradesService")
public class TradingSpotTradesServiceImpl extends ServiceImpl<TradingSpotTradesMapper, TradingSpotTrades> implements TradingSpotTradesService {

    @Override
    public List<TradingSpotTrades> listByOrderId(Integer orderId, Boolean isBuy) {
        LambdaQueryWrapper<TradingSpotTrades> queryWrapper = new QueryWrapper<TradingSpotTrades>().lambda();
        if(isBuy){
            queryWrapper.eq(TradingSpotTrades::getBuyOrderId, orderId);
        }else {
            queryWrapper.eq(TradingSpotTrades::getSellOrderId, orderId);
        }
        queryWrapper.orderByDesc(TradingSpotTrades::getId);
        return list(queryWrapper);
    }

}
